function noop(){}

function Alphascroll(ctx, {
	letterHeight = 40, // 单位为rpx
	onShow = noop,// ohShow(letter)
	onTap = noop, // onTap(event)
} = {}){
	const { windowWidth } = wx.getSystemInfoSync();

	ctx.alphascroll_bindTouchStart = function(e){
		// 没办法取手指触碰元素的位置相对于列表顶部的高度，所以取触碰元素的中点相对于列表顶部的高度
		this.startTop = e.target.offsetTop + letterHeight/2;
		this.startX = e.touches[0].clientY;
	}

	ctx.alphascroll_bindTouchMove = function(e){
		var y = this.startTop + (e.touches[0].clientY - this.startX),
			letterH = parseInt(letterHeight/(750/windowWidth));
        var selectedLetter = ctx.data.alphascroll.alphabet[parseInt(y/letterH)];
        if(selectedLetter){
        	onShow(selectedLetter);
        }
	}

	ctx.alphascroll_bindLetterTap = function(e){
		onTap(e);
	}
}

module.exports = Alphascroll;